package com.blue.base.demo.entity;

import com.alibaba.fastjson.JSON;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import lombok.Data;
import lombok.experimental.Accessors;

import java.io.Serializable;
import java.util.Objects;

/**
 * <p>
 * 角色和菜单关联表
 * </p>
 *
 * @author liulei, lei.liu
 * @version 1.0
 */
@Data
@Accessors(chain = true)
public class RoleMenu implements Serializable {

    private static final long serialVersionUID = 1L;

    /**
     * 主键
     */
    @TableId(value = "id", type = IdType.AUTO)
    private Long id;

    /**
     * 菜单id
     */
    @TableField("menu_id")
    private Long menuId;

    /**
     * 角色id
     */
    @TableField("role_id")
    private Long roleId;

    @Override
    public boolean equals(Object object) {
        if (this == object) {
            return true;
        }
        if (object == null) {
            return false;
        }
        if (object instanceof RoleMenu) {
            RoleMenu roleMenu = (RoleMenu) object;
            return Objects.equals(roleMenu.getRoleId(), roleId)
                    && Objects.equals(roleMenu.getMenuId(), menuId);
        }
        return false;
    }

    @Override
    public int hashCode() {
        int result = 0;
        result = 31 * result + Objects.hashCode(menuId);
        result = 31 * result + Objects.hashCode(roleId);
        return result;
    }

    @Override
    public String toString() {
        return JSON.toJSONString(this);
    }
}
